<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue-2.6.12.js"></script>
</head>
<body>
  <div id="app">
    <ul>
      <li v-for="(item) in products">{{item.name}}</li>
    </ul>
    <button @click="changeByd()">点我修改</button>
  </div>

  <script>
    new Vue({
      el:"#app",
      data:{
        products:[{id:1,name:"su7",price:21},{id:2,name:"byd",price:21}]
      },
      methods:{
        changeByd:function(){
          //在vue2版本里面，我们直接修改数组某个下标的元素时，vue不会影响到视图view，vue给我们了相关解决办法
          // this.products[1]={id:2,name:"lixiang",price:21};
          this.$set(this.products,1,{id:2,name:"lixiang",price:21});
        }
      }
    });
  </script>
</body>
</html>